"use strict";

// const Storage = require("ee-core/storage");
const _ = require("lodash");
const path = require("path");

/**
 * 系统元数据服务
 * @class
 */
class metadbService  {
  init() {

    this.jsonFile = "db_meta";
    this.demoDB = Storage.connection(this.jsonFile);
    this.demoDBKey = {
      nickname: "nickname",
      subject: "subject",
      gender: "gender",
    };
  }

  async getData(key="") {

    if (!this.demoDB.db.has(key).value()) {
      this.demoDB.db.set(key, []).write();
    }
    let data = this.demoDB.db.get(key).value();
    if (_.isEmpty(data)) {
      data = [];
    }
    return data;
  }

}

metadbService.toString = () => "[class metadbService]";
module.exports = metadbService;
